package com.xunk.common.core.enums.dnake;

import com.xunk.common.core.interfaces.EnumValidateInterface;

/**
 * @Author: wangTong
 * @Description: 狄耐克cmd命令枚举
 * @Date: 2021/5/12 10:50
 * @Version: 1.0
 */
public enum DnakeCmdEnum implements EnumValidateInterface {

    ON("on", "设备开"),
    OFF("off", "设备关"),
    LEVEL("level", "对于调光面板，表示亮度值；对于窗帘面板，表示窗帘的拉开程度。"),
    COLORXY("colorxy", "色坐标"),
    SAT("sat", "饱和度"),
    COLORTEMP("colorTemp", "色温值"),
    MULATTRIBUTE("mulAttribute", "多属性控制"),
    STOP("stop", "停止"),
    SIRENSET("sirenSet", "打开声光报警器及参数设置"),
    IRSEND("irSend", "红外键码发送，红外设备控制"),
    IRMATCH("irMatch", "红外设备匹配"),
    IRCFG("irCfg", "红外设备进入学习状态"),
    IRCANCEL("irCancel", "红外设备退出学习状态"),
    IRDEL("irDel", "红外设备删除单个红外键码"),
    IRDELALL("irDelAll", "红外设备删除全部红外码"),

    irDownLoad("irDownLoad", "红外设备导入红外码库");

    private String code;
    private String desc;

    DnakeCmdEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code){
        for(DnakeCmdEnum dnakeActionEnum : DnakeCmdEnum.values()){
            if(dnakeActionEnum.getCode().equals(code)){
                return dnakeActionEnum.getDesc();
            }
        }
        return null;
    }

    /**
     * 判断是否是可用枚举
     *
     * @param code
     * @return
     */
    @Override
    public Boolean isValidEnum(String code) {
        for (DnakeCmdEnum value : DnakeCmdEnum.values()) {
            if (value.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

}
